//
//  JingPinCell.m
//  MyTest
//
//  Created by zhiyou on 16-4-14.
//  Copyright (c) 2016年 wangyang. All rights reserved.
//

#import "JingPinCell.h"

@implementation JingPinCell

- (void)awakeFromNib {
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _headView = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_headView];
        
        [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.offset(10);
            make.bottom.offset(-10);
            make.width.equalTo(_headView.mas_height);
        }];
        
        _titleLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _titleLab.font = [UIFont systemFontOfSize:14];
        _titleLab.numberOfLines = 2;
        [self.contentView addSubview:_titleLab];
        
        [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(10);
            make.top.offset(10);
            make.right.offset(-10);
        }];
        
        _subLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _subLab.font = [UIFont systemFontOfSize:14];
        _subLab.textColor = [UIColor redColor];
        [self.contentView addSubview:_subLab];
        
        [_subLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(10);
            make.top.equalTo(_titleLab.mas_bottom).offset(10);
            make.right.offset(-10);
        }];
        
        _sourceLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _sourceLab.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_sourceLab];
        
        [_sourceLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView.mas_right).offset(10);
            make.width.offset(Width/3);
            make.top.equalTo(_subLab.mas_bottom).offset(10);
        }];
        
        _hitsLab = [[UILabel alloc] initWithFrame:CGRectZero];
        _hitsLab.font = [UIFont systemFontOfSize:11];
        _hitsLab.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_hitsLab];
        
        [_hitsLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.offset(-10);
            make.top.equalTo(_subLab.mas_bottom).offset(10);
        }];
    }
    return self;
}
- (void)setTopic:(Topic *)topic
{
    _topic = topic;
    [_headView sd_setImageWithURL:[NSURL URLWithString:_topic.img_url]];
    _titleLab.text = _topic.title;
    _subLab.text = _topic.subTitle;
    _sourceLab.text = [NSString stringWithFormat:@"商家: %@",_topic.business];
    _hitsLab.text = [NSString stringWithFormat:@"%@已关注",_topic.hits];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
